<?php

include '../vendor/autoload.php';

use Web3\Web3;
use Web3\Providers\HttpProvider;
use Web3\RequestManagers\HttpRequestManager;

use Web3\Utils;

use EthTool\Callback;
use EthTool\Credential;

$cb = new Callback;

// $web3 = new Web3(new HttpProvider(new HttpRequestManager('https://data-seed-prebsc-1-s1.binance.org:8545', 5)));
$web3 = new Web3(new HttpProvider(new HttpRequestManager('http://127.0.0.1:8545', 5)));

$web3->clientVersion($cb);
echo '客户端版本: ' , $cb->result,PHP_EOL;

// $web3->sha3('hello,ethereum',$cb);
// echo $cb->result . PHP_EOL;

$web3->eth->gasPrice($cb);
echo '汽油价格(单位: wei): ',$cb->result , PHP_EOL;

$web3->eth->accounts($cb);
$accounts = $cb->result;
print_r($accounts);

$web3->eth->getBalance($accounts[0],$cb);
echo '账户地址:0','余额(单位: wei):',$cb->result . PHP_EOL;
